package com.pms.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.pms.system.domain.vo.PmsGuestroomInfoVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pms.common.annotation.Log;
import com.pms.common.core.controller.BaseController;
import com.pms.common.core.domain.AjaxResult;
import com.pms.common.enums.BusinessType;
import com.pms.system.domain.PmsGuestroomInfo;
import com.pms.system.service.IPmsGuestroomInfoService;
import com.pms.common.utils.poi.ExcelUtil;
import com.pms.common.core.page.TableDataInfo;

/**
 * 客房信息Controller
 * 
 * @author 达瓦里氏
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/PmsGuestroomInfo")
public class PmsGuestroomInfoController extends BaseController
{
    @Autowired
    private IPmsGuestroomInfoService pmsGuestroomInfoService;

    /**
     * 查询客房信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmsGuestroomInfo pmsGuestroomInfo)
    {
        startPage();
        List<PmsGuestroomInfoVo> list = pmsGuestroomInfoService.selectPmsGuestroomInfoList(pmsGuestroomInfo);
        return getDataTable(list);
    }

    /**
     * 查询客房信息列表LIst
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:roomInfoList')")
    @GetMapping("/roomInfoList")
    public List<PmsGuestroomInfoVo> roomInfoList(PmsGuestroomInfo pmsGuestroomInfo)
    {
        List<PmsGuestroomInfoVo> list = pmsGuestroomInfoService.selectPmsGuestroomInfoList(pmsGuestroomInfo);
        return list;
    }

    /**
     * 导出客房信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:export')")
//    @Log(title = "客房信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmsGuestroomInfo pmsGuestroomInfo)
    {
        List<PmsGuestroomInfoVo> list = pmsGuestroomInfoService.selectPmsGuestroomInfoList(pmsGuestroomInfo);
        ExcelUtil<PmsGuestroomInfoVo> util = new ExcelUtil<PmsGuestroomInfoVo>(PmsGuestroomInfoVo.class);
        util.exportExcel(response, list, "客房信息数据");
    }

    /**
     * 获取客房信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmsGuestroomInfoService.selectPmsGuestroomInfoById(id));
    }

    /**
     * 新增客房信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:add')")
//    @Log(title = "客房信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsGuestroomInfo pmsGuestroomInfo)
    {
        return toAjax(pmsGuestroomInfoService.insertPmsGuestroomInfo(pmsGuestroomInfo));
    }

    /**
     * 修改客房信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:edit')")
//    @Log(title = "客房信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsGuestroomInfo pmsGuestroomInfo)
    {
        return toAjax(pmsGuestroomInfoService.updatePmsGuestroomInfo(pmsGuestroomInfo));
    }

    /**
     * 删除客房信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomInfo:remove')")
//    @Log(title = "客房信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsGuestroomInfoService.deletePmsGuestroomInfoByIds(ids));
    }


    /**
     * 客房清理
     */
    @GetMapping("/housekeeping/{ids}")
    public void housekeeping(@PathVariable Long[] ids)
    {
        pmsGuestroomInfoService.housekeeping(ids);
    }
}
